
package com.joysuch.wwyt.core.enums;

public enum FileConvertStates {

    NOT_START(0, "未开始"),
    PROGRESSING(1, "进行中"),
    SUCCESS(2, "转换成功"),
    FAILED(3, "转换失败"),
    DO_NOT_SUPPORT(4, "不支持转换"),
    DO_NOT_NEED(5, "无需转换");

    int code;
    String name;

    private FileConvertStates(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public boolean is(Integer state) {
        return state != null && state.intValue() == code;
    }

    public static String findNameByCode(Integer code) {
        if (code == null) {
            return null;
        }
        FileConvertStates[] values = FileConvertStates.values();
        for (FileConvertStates s : values) {
            if (s.code == code.intValue()) {
                return s.getName();
            }
        }
        return null;
    }
}
